/****************************************************************\

Copyright 2004 Enzo Michelangeli

This file is part of the KadC library.

KadC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

KadC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KadC; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

In addition, closed-source licenses for this software may be granted
by the copyright owner on commercial basis, with conditions negotiated
case by case. Interested parties may contact Enzo Michelangeli at one
of the following e-mail addresses (replace "(at)" with "@"):

 em(at)em.no-ip.com
 em(at)i-t-vision.com

\****************************************************************/

#include <time.h>


#define ON 1
#define OFF 0
/*
Edited by James Tyra to add a level
This allows you to create specific levels or types to log
*/
#define ERROR_PRINT 0
/* Logging for error messages */

#define GENERAL_PRINT 1 
/* This is the general print level for most output */

#define VERBOSE_PRINT 2
#define FINDNODE_PRINT 3
/* This is for logging information related to a find node query */

#define SPECIAL_PRINT 4
/* Custom designed print flag */

#define STARTUP_PRINT 5
/* Flag for printing startup info, such as bootstrap */

#define MSGTYPE_PRINT 6
#define RTABLE_PRINT 7
#define SEARCH_PRINT 8
#define BOT_PRINT 9

/* opens filename in append mode and uses it as logfile
   (internally calls KadClog_setfile() */
FILE *KadClog_open(char *filename);

/* use as logfile the open stream pointed by the parameter
   if not set here or by KadClog_open(), logfile defaults to stdout */
void KadClog_setfile(FILE **f);
/* like fprintf(f, fmt, ...) but mutex-locking with log output */
void KadC_flog(int level, FILE *f, const char *fmt, ...);
/* like fprintf(logfile, fmt, ...) but mutex-locking with log output */
void KadC_log(int level, const char *fmt, ...);
/* as above, but line is prefixed by ctime(NULL) */
void KadC_logt(int level, const char *fmt, ...);

void KadC_logt_parsed(unsigned char* data, unsigned long int src_ip);

/* like fgets(s, size, stdin) but mutex-locking with log output */
char *KadC_getsn(char *s, int size);

void KadClog_set_start_time(void);

void KadClog_set_start_dvn_time(struct timeval dvn_time);

void KadClog_set_current_dvn_time(struct timeval dvn_time);

time_t KadClog_get_current_dvn_time();

/* like fprintf for int128 data types in %32x format and mutex-locking with log output 
void KadC_int128flog(FILE *f, int128 i128);
void KadC_int128log(int128 i128);
*/

/**
 * Function pointer to get (possibly simulated) time
 */
typedef time_t (*dvn_gettime)();

/**
 * Set the function for time.  If NULL, return regular time(NULL)
 * Return the old value for dvn_gettime func
 */
dvn_gettime KadClog_set_time_func(dvn_gettime time_func);

